<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<div class="board_contents">
	<h1>Board</h1>
	<table id="board_table">
		<tr>
			<th>No</th>
			<th>Title</th>
			<th>Writer</th>
			<th>Date</th>
			<th>Hit</th>
		</tr>
		<c:set var="date" value="<%=new java.util.Date() %>" />
		<c:forEach items="${boardList }" var="board">
			<tr>
				<td>${board.empBoardNo }</td>
				<td class="left">
				<a onclick="board_contents(${board.empBoardNo}, ${pageNum })" >${board.title }[${board.commentCount }]</a></td>
				<td>${board.name }</td>
				<td>
					<c:choose>
					<c:when test="${board.writeDate.getMonth() == date.getMonth()
					&& board.writeDate.getDate() == date.getDate() }">
						<fmt:formatDate value="${board.writeDate}" pattern="hh:mm:ss" />
					</c:when>
					<c:otherwise>
						<fmt:formatDate value="${board.writeDate}" pattern="YYYY/MM/dd" />
					</c:otherwise>
				</c:choose>
				</td>
				<td>${board.readCount }</td>
			</tr>
		</c:forEach>
	</table>
	<div id="paging">
	<img id="paging_prev" src="resources/images/page-arrow-left.jpg" />
	<c:forEach var="i" begin="1" end="${(boardCount / 10) + 1 }">
		<c:choose>
			<c:when test="${i == pageNum }">
				<a class="onclick"> ${i } </a>
			</c:when>
			<c:otherwise>
				<a  onclick="board_list_with_num(${i})"> ${i } </a>
			</c:otherwise>
		</c:choose>
	</c:forEach>
	<img id="paging_next" src="resources/images/page-arrow-right.jpg"/>
	</div>
	<script>
		$(document).ready(function(){
			var pageNum = ${pageNum};
			var lastPage =parseInt("${(boardCount / 10) + 1 }");
			
			if(pageNum != 1){
				$('#paging_prev').unbind('click');
				
				$('#paging_prev').click(function(){
					board_list_with_num(pageNum-1);
				});
			}
			
			if(pageNum != lastPage){
				$('#paging_next').unbind('click');
				
				$('#paging_next').click(function(){
					board_list_with_num(pageNum+1);
				});
				
				
			}
		});
	</script>
	
	<div>
	<input type="button" value="Write"id="write_btn" class="btn" onclick=board_write()></a> 
	<input type="text" class="input_box"> 
	<input type="button" value="Search" id="search_btn" class="btn">
	</div>
	
</div><!-- board_contents end div -->

</div><!-- board end div  -->

